﻿#region itdc

/************************************************************************
*Copyright(C) 2015 by qsgy
 *All rights reserved. 
 *FileName:     $safeitemname$
 *Author:       oyh
 *Version:      
 *UnityVersion：
 *Date:   $time$      
 *Description:    
 *History: 
************************************************************************/
#endregion
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 状态改变激活器
/// 当本身的状态机发生改变时 激活目标
/// </summary>
public class StateActiva : Activator
{
    [Tooltip("前一个状态。为空则不考虑")]
    public StateID before = StateID.Null;
    [Tooltip("转换后的转态。为空则不考虑")]
    public StateID after = StateID.Null;

    private void Awake()
    {
        GetComponent<FSMSystem>().OnStateIdChange += Act;
    }

    protected virtual void Act(StateID before,StateID after)
    {
        if (before != this.before && this.before != StateID.Null) return;
        if (after != this.after && this.after != StateID.Null) return;
        SetAct(true);
    }
}
